home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8823 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  58 lines

  1. Newsgroups: comp.lang.c++
  2. Path: uhura.cc.rochester.edu!sc006e
  3. From: sc006e@uhura.cc.rochester.edu (Scott Crosby)
  4. Subject: Re: Template Troubles
  5. Message-ID: <1996Feb26.174908.25284@galileo.cc.rochester.edu>
  6. Sender: news@galileo.cc.rochester.edu
  7. Nntp-Posting-Host: uhura.cc.rochester.edu
  8. Organization: University of Rochester - Rochester, New York
  9. References: <4grbtb$nog@aimnet.aimnet.com>
  10. Distribution: usa
  11. Date: Mon, 26 Feb 96 17:49:08 GMT
  12.  
  13. In <4grbtb$nog@aimnet.aimnet.com> krisb@aimnet.com (Kris Bosland) writes:
  14.  
  15. >    I have just discovered Templates in C++, and I am trying to use them 
  16. >for the same thing that everyone else uses them for: Linked Lists.  I am 
  17. >trying to get even a basic template class going, and it is not working.  I am 
  18. >running g++ 2.7.0 on my Linux 1.2.13 system (vanilla Slackware 3.0).  Files:
  19.  
  20. >test.cc:
  21. >----------------------------------------------------------------
  22. >template <class data_t> class List {
  23. >  public:
  24. >    data_t data;
  25. >}  ;
  26.    ^^^
  27. ***** I think you need a semicolon here |
  28.  
  29. >void main( int argc, char **argv )
  30. >{
  31. >  List<char *> string_list;
  32.  
  33. >}
  34. >----------------------------------------------------------------
  35.  
  36. >Compiler Results:
  37. >----------------------------------------------------------------
  38. >g++ -g -o test test.cc
  39. >test.cc:7: parse error before `void'
  40. >test.cc:9: confused by earlier errors, bailing out
  41. >make: *** [test] Error 1
  42. >----------------------------------------------------------------
  43.  
  44. >    Could I be missing some compiler flags or configuration?  I don't have 
  45. >much experience customizing gcc/g++.  In a more complicated file I wrote, I 
  46. >got errors complaining about incomplete typing of the data member of my class.
  47.  
  48.  
  49.  
  50. >                    -Kris Bosland
  51. >                     krisb@aimnet.com
  52. >                     http://www.seattleu.edu/~krisb/
  53. -- 
  54. *************************************************************************
  55. *                Scott Crosby                *
  56. *                    sc006e@uhura.cc.rochester.edu        *
  57. *************************************************************************
  58.